{include file="public_iframe:head"}
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/lang/zh-cn/zh-cn.js"></script>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>

            </h5>
            <div class="ibox-tools" style="margin-top: -9px;">
                <a href="javascript:history.go(-1);" class="btn btn-primary"><i class="fa fa-arrow-left"></i> 返回</a>
            </div>
        </div>
        <div class="ibox-content">
            <mvc:resources mapping="/static/**" location="__STATIC__/editor/lang/zh-cn/zh-cn.js" /><!--注:static为我的静态资源文件夹-->

            <form action="" method="post" enctype="multipart/form-data" id="brandForm" class="form-horizontal">
                    <input type="hidden" name="id" value="{$da.id?$da.id:'';}">
                    {if condition="$type=='5'"}<input type="hidden" name="type2"  value="5" >{/if}
                    <div class="form-group">
                    {if condition="$type!='5'"}
                    <label class="col-sm-2 control-label">所属位置</label>

                    <div class="col-sm-6">
                        
                        <label class="checkbox-inline">
                            <input type="radio" name="type"  value="1"  {if condition="isset($da.type) and $da.type=='1'"} checked="checked"{/if}>如何赚佣金
                        </label>
                        <label class="checkbox-inline">
                            <input type="radio" name="type"  value="2" {if condition="isset($da.type) and $da.type=='2'"} checked="checked"{/if}>
                            广告投放
                        </label>
                        <label class="checkbox-inline">
                            <input type="radio" name="type"  value="3" {if condition="isset($da.type) and $da.type=='3'"} checked="checked"{/if}>
                            关于淘一
                        </label>
                        <label class="checkbox-inline">
                            <input type="radio" name="type"  value="4" {if condition="isset($da.type) and $da.type=='4'"} checked="checked"{/if}>
                            客服中心
                        </label>
                        
                   <!--       <label class="checkbox-inline">
                            <input type="radio" name="type"  value="5" {if condition="isset($da.type) and $da.type=='5'"} checked="checked"{/if}>
                            公告栏目
                        </label> -->
                        
                    </div>
                    {/if}

                </div>
                    <input type="hidden" name="type" value="5" >
                    <div class="form-group">
                        <label class="col-sm-2 control-label">标题</label>
                        <div class="col-sm-6">
                            <input type="text" name="title" id="title" value="{$da.title?$da.title:'';}" class="form-control" placeholder="文章标题" >
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">客服电话</label>
                        <div class="col-sm-6">
                            <input type="text" name="phone" id="phone" value="{$da.phone?$da.phone:'';}" class="form-control" placeholder="电话" >
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                     <div class="form-group">
                        <label class="col-sm-2 control-label">微信客服</label>
                        <div class="col-sm-6">
                            <input type="text" name="wx" id="wx" value="{$da.wx?$da.wx:'';}" class="form-control" placeholder="微信" >
                        </div>
                    </div>
                    {if $type!='5'}
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">图片</label>
                        <div class="col-sm-6">
                            <input type="file" name="picture" class="form-control">{if condition="isset($da.picture)"}(备注: 宽度  高度;)<img src="{$da.picture}" alt="">{/if}
                        </div>
                    </div>
                    {/if}
                    
                    <div class="hr-line-dashed"></div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">内容</label>
                        <script id="editor" name="content" type="text/plain"  style="width:700px;height:300px;margin-left:290px; margin-top:-12px;">{$da.content?$da.content:''}</script>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-2">
                            <!--<button class="btn btn-primary" type="submit">提交</button>-->
                            <!--href="JavaScript:void(0);" onclick="roleSubmit();"-->
                            <a href="JavaScript:void(0);" onclick="Submit();" class="btn btn-primary" id="submit">提交</a>
                        </div>
                    </div>
       
            </form>
        </div>
    </div>
    <!-- End Panel Basic -->
</div>
<script>
     function Submit(){
        var formData = new FormData();
        var id = $('input[name="id"]').val();
        var phone = $('input[name="phone"]').val();
        var title = $('input[name="title"]').val();
        var content = ue.getContent();
        var wx = $('input[name="wx"]').val();


      
        var type = $('input[name="type"]:checked').val();

       var type2 = $('input[name="type2"]').val();


        var file = $('input[name="picture"]');

        console.log(file);
 
        if(file.length != 0){
            var img = file.get(0).files[0];
            formData.append('picture',img);
        }
        
        if(type2){
            formData.append('type2',type2);
        }

        formData.append('id',id);
        formData.append('phone',phone);
        formData.append('title',title);
        formData.append('wx',wx);
        formData.append('type',type);
        formData.append('content',content);
        
        $.ajax({
            url:"{:url('Article/doedit')}",
            type:'POST',
            data:formData,
            async:false,
            processData:false,
            contentType:false,
            success:function(result) {
                if(result.code == '0'){
                    parent.layer.alert(result.msg);
                }else{
                    parent.layer.msg(result.msg,{
                                icon:1,
                                time:1000,
                            },
                            function (index, item) {
                                history.go(-1);
                            });
                }
            }
        });
    }
</script>
>
<script type="text/javascript">

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');


    function isFocus(e){
        alert(UE.getEditor('editor').isFocus());
        UE.dom.domUtils.preventDefault(e)
    }
    function setblur(e){
        UE.getEditor('editor').blur();
        UE.dom.domUtils.preventDefault(e)
    }
    function insertHtml() {
        var value = prompt('插入html代码', '');
        UE.getEditor('editor').execCommand('insertHtml', value)
    }
    function createEditor() {
        enableBtn();
        UE.getEditor('editor');
    }
</script>
<script type="text/javascript">
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ues = UE.getEditor('editor_two');

    function isFocus(e){
        alert(UE.getEditor('editor_two').isFocus());
        UE.dom.domUtils.preventDefault(e)
    }
    function setblur(e){
        UE.getEditor('editor_two').blur();
        UE.dom.domUtils.preventDefault(e)
    }
    function insertHtml() {
        var value = prompt('插入html代码', '');
        UE.getEditor('editor_two').execCommand('insertHtml', value)
    }
    function createEditor() {
        enableBtn();
        UE.getEditor('editor_two');
    }
</script>
</body>

</html>